let aaa = {
  data(){
    return {
      pitch: 30,
      range: 10000,
      cycle: 300,
    }
  },
  watch: {
    pitch(v) {
      this._rotate.pitch = Cesium.Math.toRadians(v);
    },
    range(v) {
      this._rotate.range = v;
    },
    cycle(v) {
      this._rotate.cycle = v;
    }
  },
  mounted() {
    let _this = this
    let viewer = this.$root._earth.czm.viewer
    let earth = this.$root._earth

    //添加飞行对象
    this._rotate = this.$root._earth.cameraFlight.rotateCenter;
    XE.MVVM.watch(() => {
      var t = this.$root._earth.cameraFlight.rotateCenter;
      this.update(t);
    });
    this.update();

    //清除默认双击事件
    viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
    viewer.screenSpaceEventHandler.setInputAction(function (movement) {
      var ray = viewer.camera.getPickRay(movement.position);
      var sanweidikaer = viewer.scene.globe.pick(ray, viewer.scene);
      let hudu = Cesium.Cartographic.fromCartesian(sanweidikaer)
      _this.range = earth.camera.position[2] + 2000
      earth.camera.flyAround([hudu.longitude,hudu.latitude,1],_this.range ,earth.camera.rotation,0,Cesium.Math.toRadians(_this.pitch))
      _this.startfly("rotateCenter")

    },Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
  },
  methods: {
    startfly(type){
      const cf = this.$root._earth.cameraFlight;
      const fly = cf.flying;

      //先停止当前的
      if (fly) {
        fly.cancel();

        //判定是否要开始，如果类型和当前一致，那么不开启
        if (fly.type == type) return;
      }

      //如果获取为空，那么也不开始
      let newFly = cf[type];
      if (newFly) {
        newFly.start();
      }
    },
    update() {
      this.pitch = Cesium.Math.toDegrees(this._rotate.pitch);
      this.range = this._rotate.range;
      this.cycle = this._rotate.cycle;
    }
  }
}

export default aaa